package com.rs.qm.modules.member.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.rs.qm.common.annotation.CacheKey;
import com.rs.qm.common.annotation.RedisCache;
import com.rs.qm.common.utils.PageUtils;
import com.rs.qm.common.utils.Query;
import com.rs.qm.modules.member.dao.FreeUserDao;
import com.rs.qm.modules.member.entity.FreeUserEntity;
import com.rs.qm.modules.member.service.FreeUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("freeUserService")
public class FreeUserServiceImpl extends ServiceImpl<FreeUserDao, FreeUserEntity> implements FreeUserService {


    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<FreeUserEntity> page = this.selectPage(
                new Query<FreeUserEntity>(params).getPage(),
                new EntityWrapper<>()
        );

        return new PageUtils(page);
    }

    @Override
    @RedisCache(cacheName = "测试key")
    public FreeUserEntity queryByUserName(@CacheKey String username) {
        return baseMapper.queryByUserName(username);
    }

}